<template>
	<view class="content">
		<uni-list>
			<uni-list-item clickable @click="handleClick(index)" :title="item.title" v-for="(item,index) in settingList"
				:key="index">
				<template slot="footer">
					<uni-icons type="right" color="#14a59a" size="20"></uni-icons>
				</template>
			</uni-list-item>
		</uni-list>
		<view class="loginout">
			当前手机号:{{phone ? phone : ''}}
		</view>
		<view class="logtext" v-for="(item,index) in titleList" :key="index">
			<view @click="btnFn(item)">{{item.title}}</view>
		</view>
		<view class="loginout" @click="handlePhoneClick">更换手机号</view>
		<!-- <view class="loginout" style="color:red" @click="handlePhoneClick">注销账户</view> -->
		<!-- #ifdef MP-ALIPAY -->
		<view class="loginout" @click="handleOutClick">退出登录</view>
		<!-- #endif -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				settingList: [],
				phone:null,
				titleList:[],
				// settingList:[{
				// 	title:'我的发票管理',
				// 	url:'/pages/miscellaneous/charge-record',//暂时隐藏开发票入口
				// },{
				// 	title:'用户协议',
				// 	url:'',
				// }]
			}
		},
		onShow(){
			this.getData();
			this.getsigninSet();
		},
		onLoad(options) {
			this.getListRequest();
		},
		methods: {
			//点击用户协议跳转
			btnFn(item){
				console.log(item);
		    //type 0:无跳转 1:h5链接  2:外部小程序
			if(item.type == 1){
				this.$utils.jumpWebview(item.url);
				/* uni.navigateTo({
					url: "/pages/webview/index?url=" + item.url
				}) */
			}else if(item.type == 2){
				console.log( item);
				uni.navigateToMiniProgram({
					appId: item.car_shop_appid,
					path: item.url_platform,
					extraData: {
						'data1': 'test'
					},
					success(res) {
						// 打开成功		
					}
				})
			}
			},
			getData() {
				this.$u.api.getPersonalCenter({
					uid: uni.getStorageSync('uid'),
				}).then(res => {
					//其它数据
					
					this.phone = res.data.phone;
					
			
				}).catch();
			
			},
			//获取用户协议列表
			getsigninSet(){
				this.$u.api.signinSet({
				}).then(res => {
					console.log(res,'res');
					this.titleList = res.data;
				}).catch(err=>{})
			},
			getListRequest() {
				this.$u.api.getSettingList().then(res => {
					if (res.result_code == 1000) {
						// this.settingList=res.data;
						this.settingList = [];
					};

				}).catch();
			},
			handleClick(index) {
				let type = this.settingList[index].type;
				if (type == 1) {
					//发票
					uni.navigateTo({
						url: '/pages/miscellaneous/charge-record'
					});
				};
			},
			handlePhoneClick() {
				uni.navigateTo({
					url: '/pages/miscellaneous/changePhone'
				});
			},
			handleOutClick() {
				this.$utils.modal({
					content: '确定要退出登录？',
					callback: (bool) => {
						if (bool) {
							this.$u.api.loginOut().then(res => {
								if (res.result_code == 1000) {

									uni.removeStorageSync('userId');
									uni.removeStorageSync('guide');
									//调用接口，跳转至首页
									uni.reLaunch({
										url: '/pages/index/index'
									});
								} else {
									this.$utils.toast(res.msg);
								};

							}).catch();

						};
					}
				});
			}
		}

	}
</script>
<style lang="scss" scoped>
	.loginout {
		margin-top: 16rpx;
		padding: 12px 15px;
		text-align: center;
		background-color: #fff;
		font-size: 32rpx;
		font-weight: 500;
		color: #010101
	}
	.logtext {
		margin-top: 10rpx;
		background-color: #fff;
		padding: 8px 15px;
		text-align: left;
		font-size: 32rpx;
		font-weight: 500;
		color: #010101
	}
</style>
<style>
	page {
		background: #F4F5F7;
	}
</style>